home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Information
/
CSMP Digest
/
volume 3
/
csmp-digest-v3-089
< prev
next >
Wrap
Text File
|
1995-12-31
|
69KB
|
1,850 lines
C.S.M.P. Digest Sat, 18 Mar 95 Volume 3 : Issue 89
Today's Topics:
Asynchronous file read-write example
Getting the real time frame rate of QT movies
Help! Scroll bars are crashing!!!
Help! JPEG-QT decompression
How can I open a System7 sound file?
Is it safe to call LaunchApplication from an extension?
My own Color Table??
Need help with calling CODE resources
Q: TextEdit view-dest rectangles - documented where?
Q: What are Exceptions?
Screen saver info needed
Transparent QuickTime?
The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
(pottier@clipper.ens.fr).
The digest is a collection of article threads from the internet newsgroup
comp.sys.mac.programmer. It is designed for people who read c.s.m.p. semi-
regularly and want an archive of the discussions. If you don't know what a
newsgroup is, you probably don't have access to it. Ask your systems
administrator(s) for details. If you don't have access to news, you may
still be able to post messages to the group by using a mail server like
anon.penet.fi (mail help@anon.penet.fi for more information).
Each issue of the digest contains one or more sets of articles (called
threads), with each set corresponding to a 'discussion' of a particular
subject. The articles are not edited; all articles included in this digest
are in their original posted form (as received by our news server at
nef.ens.fr). Article threads are not added to the digest until the last
article added to the thread is at least two weeks old (this is to ensure that
the thread is dead before adding it to the digest). Article threads that
consist of only one message are generally not included in the digest.
The digest is officially distributed by two means, by email and ftp.
If you want to receive the digest by mail, send email to listserv@ens.fr
with no subject and one of the following commands as body:
help Sends you a summary of commands
subscribe csmp-digest Your Name Adds you to the mailing list
signoff csmp-digest Removes you from the list
Once you have subscribed, you will automatically receive each new
issue as it is created.
The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
Questions related to the ftp site should be directed to
scott.silver@dartmouth.edu.
-------------------------------------------------------
>From niemann@mo.net (Jim Niemann)
Subject: Asynchronous file read-write example
Date: 1 Mar 1995 23:41:05 GMT
Organization: -=MO.NET=- P-Net, Inc's Missouri Operations
Does anyone have any Macintosh C examples of performing file reading
and writing asynchronously?
Thanks
Jim Niemann
The opinions contained herein do not represent those held by
any person living or dead.
+++++++++++++++++++++++++++
>From bb@lightside.com (Bob Bradley)
Date: 2 Mar 1995 03:45:42 GMT
Organization: SPC
In article <3j30mh$e33@Twain.MO.NET>, niemann@mo.net (Jim Niemann) wrote:
> Does anyone have any Macintosh C examples of performing file reading
> and writing asynchronously?
There's a good article in Develop about using Async routines. It has a lot
of good examples. I think the examples are all based around the PPC
ToolBox but, adapting it to use the File Manager is simple, the concepts
are the same. It's in the March 93 issue of Develop (not sure the exact
number).
+++++++++++++++++++++++++++
>From oster@netcom.com (David Phillip Oster)
Date: Thu, 2 Mar 1995 18:27:41 GMT
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
In article <3j30mh$e33@Twain.MO.NET> niemann@mo.net (Jim Niemann) writes:
>Does anyone have any Macintosh C examples of performing file reading
>and writing asynchronously?
Note that although you can call PBReadAsync and PBWriteAsync, if the
file is located on a hard disk, you won't actually get any asynchronous
behavior. PBReadAsync will do the read, call your completion routine, and
then PBReadAsync will return.
PBReadAsync returns immediately if the destination is a floppy, and the
read is truly asynchronous: when the read completes, your completion
routine will be called at interrupt time.
SCSI Manager 4.3 may have changed the picture, but that is the way things
have stood ever since SCSI Manager came out in '85.
This failure of PBReadAsync and PBWriteAsync to be truly asynchronous
means that if you do further i/o from your completion routines, you'll
be using more and more stack. Note that this is only a problem for
refNums that aren't really asynchronous.
Here is some code for you:
It is the asynchronous analog of FSRead, FARead, which takes:
a buffer to read into, the length to read, a routine to be called when
the routine completes, and a pointer to a big data structure that contains
all the parameter blocks that the interrupt-time state machine needs to
do its job. Some fields of the line->read.pb parameter block have been
pre-initialized with values like CurrentA5, and the address of the interface
completion routine, which sets up the environment and then calls the user's
completion routine.
typedef struct LineRec *LinePtr; /* forward declare LinePtr */
typedef void (*LineFunc)(LinePtr);
typedef void (*LineCompleteFunc)(ParmBlkPtr, LinePtr);
/* to get at our environment, we need to declare a record with a
ParamBlockRec as first element, and pointers after that give us what we need.
*/
typedef struct FARec {
ParamBlockRec pb;
LinePtr line; /* reference to owning line */
LineCompleteFunc complete; /* completion routine for this io. */
}FARec, *FAPtr;
/* FAReadFile - asynchronous analog of FSRead
*/
OSErr FAReadFile(Ptr buffer, long len, LineCompleteFunc lfunc, LinePtr line){
FAPtr fap;
fap = &line->readFile;
fap->pb.ioParam.ioBuffer = buffer;
fap->pb.ioParam.ioReqCount = len;
fap->complete = lfunc;
return PBReadAsync(&fap->pb);
}
--
- ------- <mail-to:oster@netcom.com> ----------
There is no sight finer than that of the planet Earth in your rearview mirror.
---------------------------
>From enrico.ballarin-dolfin@svusenet.ubs.ch
Subject: Getting the real time frame rate of QT movies
Date: Tue, 21 Feb 1995 08:49:13 +0100
Organization: Union Bank of Switzerland
Hi!
I would like to get the effective current frame rate of a playing QT
movie in real time.
The application JimTV had such a feature but is no more working with QT 2.0.
JimTV displays both the fps at which the movie was recorded AND the
current fps in real time.
Thanks in advance for hints!
Enrico
--
Enrico Ballarin Dolfin Union Bank of Switzerland
email: enrico.ballarin-dolfin@zh002.ubs.ubs.ch
enrico_ballarin_dolfin@macquality.ch
enrico@ezinfo.vmsmail.ethz.ch
--
Enrico Ballarin Dolfin Union Bank of Switzerland
email: enrico.ballarin-dolfin@zh002.ubs.ubs.ch
enrico_ballarin_dolfin@macquality.ch
enrico@ezinfo.vmsmail.ethz.ch
+++++++++++++++++++++++++++
>From sandvik@apple.com (Kent Sandvik)
Date: Sat, 04 Mar 1995 15:28:29 -0800
Organization: Apple Computer, Inc. Developer Technical Support
In article <enrico.ballarin-dolfin-2102950849130001@137.156.227.57>,
enrico.ballarin-dolfin@svusenet.ubs.ch wrote:
> Hi!
>
> I would like to get the effective current frame rate of a playing QT
> movie in real time.
> The application JimTV had such a feature but is no more working with QT 2.0.
> JimTV displays both the fps at which the movie was recorded AND the
> current fps in real time.
MoviePlayer 2.0b2 has this feature. If I would do this, there would be at
least two options:
a) lazy interpolation
count the amount of frames (video samples) in the movie using
GetNextInterestingTime, and get the duration of the movie, and divide.
b) more exact calculation while the movie plays
You install a moviedrawingcomplete proc that is triggered every time a
frame is drawn, have a counter, and calculate on the flight or later how
many frames you are drawing per known time unit.
Note that there are no hints when QT will drop frames, but
moviedrawingComplete proc is guaranteed to trigger for drawn frames. See
Tech Note QT1 (or old pre-Kent time of DTS QT-3 1.6.1 QT Features) for
info about movieDrawingComplete procs.
Just to end this more philosophically, QT has not stored notation of frame
rate with the exception of how many video samples you have in the movie,
and how long these are. The rate definition is like the gas pedal of the
car, it controls how fast the movie plays (and direction), the scale
defines how many units you could have within one 1 second period. The
underlying clock is the main clock in the universe, ticking along and
providing time for the playing movie.
--Kent
--
Kent Sandvik sandvik@apple.com Working with Multimedia stuff...
Apple Developer Technical Support. Private activities on Internet.
---------------------------
>From timmyd@netcom.com (Tim DeBenedictis)
Subject: Help! Scroll bars are crashing!!!
Date: Mon, 27 Feb 1995 19:37:36 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
I am writing some scroll bar code. It is all working fine, except when
I try to use a callback routine for tracking the thumb of the scroll
bar.
Here is the relevant part of the code:
part = FindControl ( where, window, &control );
if ( control && part )
{
upp = NewControlActionProc ( sDoControlAction );
part = TrackControl ( control, where, upp );
DisposeRoutineDescriptor ( upp );
}
The sDoControlAction() function is defined as follows:
pascal void sDoControlAction ( ControlHandle control, short part )
{
WindowPtr window;
window = (*control)->contrlOwner;
switch ( part )
{
case inButton:
case inCheckBox:
case inUpButton:
case inDownButton:
case inPageUp:
case inPageDown:
case inThumb:
break;
}
}
Again, it all works fine, EXCEPT when the mouse is clicked in the thumb
part of the scroll bar. Any other part of the scroll bar works fine.
When the mouse is clicked in the thumb, the program crashes immediately.
Stepping through with the debugger, I see that TrackControl() is not
passing my sDoControlAction() procedure the correct handle to the
scroll bar when the part code correspnds to the scroll bar thumb. It works
fine for every other part code. It DOES NOT crash if I use the default
control-tracking procedue (i.e., by passing NULL instead of sDoControlAction
to TrackControl) instead.
It also works fine if the control is anything other than a scroll bar,
with both the default tracking procedure and my own sDoControlAction
procedure.
I get the same behavior whether I load the scroll bar from a 'CNTL'
resource template, allocate it directly using NewControl(), run with
extensions on or off, use 32-bit addressing or not.
Has anybody ever seen anything like this? This is really basic code...
I've done many a scroll bar before and I've never seen anything like this.
I'm running System 7.5 on a Quadra 610 using CodeWarrior CW5. I get the
same result when I compile with THINK C 5.0.4, so I'm pretty sure it's
something I'm doing wrong, rather than a compiler bug.
Thanks in advance,
-Tim DeBenedictis
+++++++++++++++++++++++++++
>From Matt Slot <fprefect@umich.edu>
Date: 28 Feb 1995 01:41:52 GMT
Organization: University of Michigan
In article <timmydD4oBup.K7K@netcom.com> Tim DeBenedictis,
timmyd@netcom.com writes:
>Has anybody ever seen anything like this? This is really basic code...
>I've done many a scroll bar before and I've never seen anything like
this.
This is one of the inconsistencies of the Toolbox... there are 2 types of
routines that handle control actions. The first handles clicks in the
page up/down, scroll up/down parts of a control -- just what you already
have. The second handles tracking dial indicators -- like the thumb area
of the scroller, and has a totally different calling convention.
pascal void myScrollAction( ControlHandle theControl, short ctrlPart);
pascal void myDialAction(void);
You have to test which portion of the control was clicked in, then set the
track-handler based on that.
Its a stumper that took me a week to fix... hope this helps you. :)
Matt
+++++++++++++++++++++++++++
>From bb@lightside.com (Bob Bradley)
Date: 1 Mar 1995 09:05:25 GMT
Organization: SPC
In article <timmydD4oBup.K7K@netcom.com>, timmyd@netcom.com (Tim
DeBenedictis) wrote:
> I am writing some scroll bar code. It is all working fine, except when
> I try to use a callback routine for tracking the thumb of the scroll
> bar.
[Code Deleted]
> Again, it all works fine, EXCEPT when the mouse is clicked in the thumb
> part of the scroll bar. Any other part of the scroll bar works fine.
> When the mouse is clicked in the thumb, the program crashes immediately.
> Stepping through with the debugger, I see that TrackControl() is not
> passing my sDoControlAction() procedure the correct handle to the
> scroll bar when the part code correspnds to the scroll bar thumb. It works
> fine for every other part code. It DOES NOT crash if I use the default
> control-tracking procedue (i.e., by passing NULL instead of sDoControlAction
> to TrackControl) instead.
For some reason, TrackControl doesn't use the same action proc when
dealing with inThumb hits. There's been quite a few messages about this
lately, if it's not in the FAQ, it probably should be.
+++++++++++++++++++++++++++
>From jaks@netcom.com (Eric Jackson)
Date: Wed, 1 Mar 1995 18:08:23 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
In article <bb-2903950105100001@user33.lightside.com>,
Bob Bradley <bb@lightside.com> wrote:
>In article <timmydD4oBup.K7K@netcom.com>, timmyd@netcom.com (Tim
>DeBenedictis) wrote:
>
>> I am writing some scroll bar code. It is all working fine, except when
>> I try to use a callback routine for tracking the thumb of the scroll
>> bar.
>
>
>For some reason, TrackControl doesn't use the same action proc when
>dealing with inThumb hits. There's been quite a few messages about this
>lately, if it's not in the FAQ, it probably should be.
The reason is that the scroll bar thumb is an indicator.
On page 336 of inside machintosh volume one you will find
Action Procedure for TrackControl
If an indicator Procedure MyAction
If not an indicator Procedure MyAction(theControl:ControlHandle;PartCode:integer);
I had this exact same trouble. Think is that according to the user interface
guidelines while the user is moving the thumb around you dont really need to do
anything. But when the user lets up on the mouse you need to find out how
far the mouse has moved and scroll accordingly after the call to TrackControl
is over.
What I have found works is that you need to have two calls to track
control. One for if the user clicked in the thumb and one for if the
user did not click in the thumb. It the user clicked in the thumb
then pass nil to TrackControl but if the user clicked in one of the
other parts of the scroll bar pass your action procedure.
Here is an example
function ScrollBar.GetActionProc: ProcPtr;
{This method is called from ControlObject.HandleMouseDownEvent. }
{What it does is to provide the action procedure that we will pass}
{to the ToolBox routine TrackControl. We need to override this}
{method for the ScrollBar because it needs to pass nil when the}
{user clicks in the thumb and its normal at all other times}
{The ScrollBar does not have its}
{own HandleMouseDownEvent method but instead }
{inherites it from the ControlObject. }
{When the user clicks the mouse down in a ScrollBar,}
{ControlObject.HandleMouseDownEvent is called from}
{ MouseDownEvent.HandleEvent which is called as an}
{inherited method from ScrollEvent.HandleEvent from the main program.}
{Normally we use the inherited method for geting }
{the action procedure but when the user has clicked in}
{the Thumb we need to return nil here since we are working with an indicator.}
{The inherited method by the way returns }
{StandardControlActionProc which works by calling}
{ScrollBar.CallFromInsideTrackControl.}
begin
if Action <> inthumb then
GetActionProc := inherited GetActionProc
else
GetActionProc := nil;
{If the user clicks in the thumb we need to return nil here since the thumb is}
{an indicator}
end;
Here is the method which called it.
procedure ControlObject.HandleMouseDownEvent;
{When the user clicks the mouse down in a ControlObject }
{in a regular window then this method is called.}
{If except if the ControlObject}
{is in an Active DialogWindow we}
{would call DialogWindow.HandleAnyEvent}
{Much of the work of this method is done by calling the }
{ToolBox routine TrackControl. For example}
{when the user clicks the mouse down in a ScrollBar }
{in a region other than the Thumb then}
{this TrackControl is called so that we can use the }
{StandardControlObjectActionProc to do the rest of the work}
{for the control. StandardControlObjectActionProc }
{uses the ControlHandle to find the ControlObject and}
{then calls the ControlObject.CallFromInsideTrackControl .}
{For example the ScrollBar.CallFromInsideTrackControl method}
{will do the rest of the work of scrolling. }
{If however the user has clicked on the thumb, since it}
{is an indicator the}
{ScrollBar.GetActionProcedure returns nil and nothing }
{is done until the user lets up on the mouse and}
{then the ScrollBar.DoAfterTracking takes care of the }
{work of moving to the new correct scroll possition.}
{In the MacWireFrame application the WireFrameWindows }
{have six buttons named Tx,Ty,Tz,Rx,Ry and}
{Rz. These are AppleEventDrivenControls work by }
{sending an AppleEvent to the MasterMessageReciever,}
{which then takes control till the user lets the mouse up.}
{When the user clicks on one of the Dxy, Dyz or Dzx radio buttons in the }
{upper left hand side of the MacWireFrame window nothing happens }
{inside track control but when the user lets up on the mouse}
{ the SetDragModeRadioButton.DoAfterTracking;}
{which overrides the standard ControlObject}
{ method is called to handle the work. }
{SetDragModeRadioButton calls the}
{inherited method RadioButton.DoAfterTracking }
{in order to do the work of Switching the Button. }
{This method is also called when the user clicks }
{the mouse down in the ToolPaletteDialog in the}
{MacSolidModel application in one of the two }
{special RadioButtons named Solid and WireFrame when}
{the ToolPaletteDialog is NOT the active or }
{front most window. When this happens isDialogEvent returns}
{false durring classification so we wind up }
{with a StandardControlEvent which calls }
{MouseDownEvent.HandleEvent as an inherited }
{method which calls this method.}
{So this is how we implement a sort of floating window}
var
Mercury: point;
PartCode: integer;
begin
getMouse(Mercury);
Window(self.AssociatedWith).ClipRectSetToWholeWindow;
Self.StartTracking := True;
StartingValue := Self.GetControlValue;
PartCode := TrackControl(Self.theControlHandle, mercury, SElf.GetActionProc);
Self.DoAfterTracking(PartCode);
Window(self.AssociatedWith).ClipRectSetToClipControls;
end;
Hope this is of some help. I got that tip about TrackControl
from the net so now I felt that I needed to pass it on.
Eric Jackson
jaks@netcom.com
---------------------------
>From hy@ix.netcom.com (Michael Hooton)
Subject: Help! JPEG-QT decompression
Date: 28 Feb 1995 08:07:45 GMT
Organization: Netcom
My application requires decompression of JPEG files. The files were
originally compressed on an IBM, then transferred in block format over
TCP/IP to a Tandem mainframe. My application downloads it to the Mac.
Currently I write it in block format to a file. Using a shareware JPEG
viewer I can see the picture but the viewer reports the data is
corrupted and the picture appears distorted.
I have three questions;
1) I attempt to decompress it using QT's DeCompress() which requires an
ImageDesrciptionRec. Is the data for this embedded in the JPEG file,
and if so where?
2) Could the data corruption be the result of a failure to swapint on
the part of the application that creates and uploads the file? Are
there integer or long fields in the JPEG header?
3) Is my approach completely erroneous or just what is the best way to
display a JPEG file?
+++++++++++++++++++++++++++
>From ivanski@world.std.com (Ivan M CaveroBelaunde)
Date: Thu, 2 Mar 1995 04:45:17 GMT
Organization: The World Public Access UNIX, Brookline, MA
hy@ix.netcom.com (Michael Hooton) writes:
>I have three questions;
>1) I attempt to decompress it using QT's DeCompress() which requires an
>ImageDesrciptionRec. Is the data for this embedded in the JPEG file,
>and if so where?
Somewhere in the sample code for QT there's some code that tells
you how to extract the information from the JFIF header in order
to build an image description rec. Basically for the
JPEG description rec all you really need is the image size (all
the other fields you can figure otherwise). You can also look
at the jpegview code.
-Ivan
- -
Ivan Cavero Belaunde (ivanski@world.std.com, ivan_cavero-belaunde@avid.com)
Avid Technology, Inc.
+++++++++++++++++++++++++++
>From sandvik@apple.com (Kent Sandvik)
Date: Sat, 04 Mar 1995 15:34:14 -0800
Organization: Apple Computer, Inc. Developer Technical Support
In article <D4sqJI.4rM@world.std.com>, ivanski@world.std.com (Ivan M
CaveroBelaunde) wrote:
> hy@ix.netcom.com (Michael Hooton) writes:
>
> >I have three questions;
> >1) I attempt to decompress it using QT's DeCompress() which requires an
> >ImageDesrciptionRec. Is the data for this embedded in the JPEG file,
> >and if so where?
>
> Somewhere in the sample code for QT there's some code that tells
> you how to extract the information from the JFIF header in order
> to build an image description rec. Basically for the
> JPEG description rec all you really need is the image size (all
> the other fields you can figure otherwise). You can also look
> at the jpegview code.
Yes, the sample is called JPEG File Interchange format, and if you search
in the DTS sample code archives on ftp.info.apple.com, eWorld, AppleLink,
developer CDs and any other place that has them, get the archive called
Movie Data Exchange.
The image description record is not automatically embedded in the JPEG
file, unless you had stored it originally under Mac inside a resource, or
somewhere else in the file. But JFIF should give you the necessary
meta-information in order to build an image description record.
--Kent
--
Kent Sandvik sandvik@apple.com Working with Multimedia stuff...
Apple Developer Technical Support. Private activities on Internet.
+++++++++++++++++++++++++++
>From Martin Frick <mfricke@indirect.com>
Date: Tue, 7 Mar 1995 05:10:12 GMT
Organization: Internet Direct, indirect.com
Subject: Re: Help! JPEG/QT decompression
From: Kent Sandvik, sandvik@apple.com
Date: Sat, 04 Mar 1995 15:34:14 -0800
In article <sandvik-0403951534140001@17.255.38.138> Kent Sandvik,
sandvik@apple.com writes:
>In article <D4sqJI.4rM@world.std.com>, ivanski@world.std.com (Ivan M
>CaveroBelaunde) wrote:
>
>> hy@ix.netcom.com (Michael Hooton) writes:
>>
>> >I have three questions;
>> >1) I attempt to decompress it using QT's DeCompress() which requires
an
>> >ImageDesrciptionRec. Is the data for this embedded in the JPEG file,
>> >and if so where?
>>
>> Somewhere in the sample code for QT there's some code that tells
>> you how to extract the information from the JFIF header in order
>> to build an image description rec. Basically for the
>> JPEG description rec all you really need is the image size (all
>> the other fields you can figure otherwise). You can also look
>> at the jpegview code.
>
>Yes, the sample is called JPEG File Interchange format, and if you search
>in the DTS sample code archives on ftp.info.apple.com, eWorld, AppleLink,
>developer CDs and any other place that has them, get the archive called
>Movie Data Exchange.
>
>The image description record is not automatically embedded in the JPEG
>file, unless you had stored it originally under Mac inside a resource, or
>somewhere else in the file. But JFIF should give you the necessary
>meta-information in order to build an image description record.
>
>--Kent
>
>--
>Kent Sandvik sandvik@apple.com Working with
Multimedia stuff...
>Apple Developer Technical Support.
Private
>activities on Internet.
You may be interested in the fact that there is a bug in my somewhat old
download of this code. (This may have been put right, I have had no
reason
to look at more recent versions.)
They (Apple DTS) have a function
char *
MarkerDetect(char *byteStream,short *width,short *height,long *hRes,long
*vRes,short *depth)
which runs to a couple of hundred lines or so with many local variables,
and
about half way through some checks occur like
switch ( tn=(dac_t2 & 0xf0) ) {
case 0:
case 0x10:
break;
case 0xf0:
break;
default:
status = 34;
break;
where the default is an error. Now, in many JFIF files the local variable
dac_t2
is never assigned by the running code. It also turns out that it, and all
the
other local variables, are not initialized. If the function is compiled
with
a Symantec compiler it runs fine, if you compile it with CW it can give
an error even with a good JFIF file.
Remedy: initialize those variables. Thus (at least)
short c1=0,hv1=0,q1=0,c2=0,hv2=0,q2=0,c3=0,hv3=0,q3=0;
short dac_t1=0, dac_t2=0, dac_t3=0;
Hope this may be a help to someone-- it certainly puzzled me for a while.
Sincerely,
M.
---------------------------
>From smithab@forbin.syr.edu (core dumped)
Subject: How can I open a System7 sound file?
Date: 4 Mar 1995 18:56:24 GMT
Organization: Syracuse University, Syracuse, NY
Hi, I would like to be able to open a 'System 7' sound file, and obtain a
handle to the SoundData of the first 'snd ' resource it contains, but I
can't figure out how to do this!
Sadly, none of Apple's Sound Snippets do anything with sound FILES, and
IM has nothing to offer here either. I looked in IM Files, and IM
Sound... Nothing!
Any help would be great!
Adam Smith
smithab@mailbox.syr.edu
Syracuse University
Dept. of Electrical Engineering
+++++++++++++++++++++++++++
>From James Wilson <WILSON_J@4j.lane.edu>
Date: 4 Mar 1995 23:02:28 GMT
Organization: University of Oregon
smithab@forbin.syr.edu (core dumped) wrote:
> Hi, I would like to be able to open a 'System 7' sound file, and obtain a
> handle to the SoundData of the first 'snd ' resource it contains, but I
> can't figure out how to do this!
> Sadly, none of Apple's Sound Snippets do anything with sound FILES, and
> IM has nothing to offer here either. I looked in IM Files, and IM
> Sound... Nothing!
>
> Any help would be great!
All that's in a System 7 sound file is a singular 'snd ' resource.
Any more and the Finder will balk at it. Since you won't know the
ID of 'snd ' resource, you must use GetIndResource, like this:
Handle soundH;
soundH = GetIndResource(soundListRsrc, 1);
This will get you the 'snd ' resource within the file.
== James Wilson <WILSON_J@4j.lane.edu>
---------------------------
>From Chris LeCroy <lecroy@ids.net>
Subject: Is it safe to call LaunchApplication from an extension?
Date: 23 Feb 1995 15:48:50 GMT
Organization: SouthBeach Software Corp.
While reading Brian Stern's excellent FAQ on system extensions I came
across the statement in answer [2] that goes - "...things that system
extensions cannot do (or at least cannot do safely), like launch
applications...".
Is it unsafe to call LaunchApplication from an extension? Was Brian
just referring to INIT time? Are there any tricks/caveats in
launching an application from a system extension?
Thanks,
+++++++++++++++++++++++++++
>From jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
Date: 25 Feb 1995 18:20:09 GMT
Organization: Queen Mary & Westfield College
In article <3il1ou$4sk@news.halcyon.com>
hawkfish@halcyon.com (Richard Wesley) writes:
> In article <3iiap2$gap@paperboy.ids.net>
> Chris LeCroy <lecroy@ids.net> writes:
>
> > While reading Brian Stern's excellent FAQ on system extensions I came
> > across the statement in answer [2] that goes - "...things that system
> > extensions cannot do (or at least cannot do safely), like launch
> > applications...".
> >
> > Is it unsafe to call LaunchApplication from an extension? Was Brian
> > just referring to INIT time? Are there any tricks/caveats in
> > launching an application from a system extension?
> >
> > Thanks,
>
> I don't believe that the process manager is running at INIT time, so _Launch
> would probably have either no effect or rather humourous effects. If you want
> to launch an app, put an alias in the Startup Items folder. You could even
> have your INIT do this (and remove it if the app was not to be launched. There
> is also some mechanism involving applications of type 'appe' but I don't
> knowwhat it involves.
>
I don't know about launching applications during startup (I've never
tried it), and I suspect that the Startup Items folder would be the
best way to do this.
However, my shareware launcher Apollo is able to use LaunchApplication
without any trouble from within its own INIT code. (Well, hardly any
trouble: there are some minor difficulties when AutoDoubler and a comms
program are running simultaneously, but that's AutoDoubler's fault).
'appe's (background-only applications) are launched in exactly the same
way as true 'APPL's. In fact, provided the file contains all the right
resources, its type seems not to be relevant.
Jeremy
+++++++++++++++++++++++++++
>From Chris LeCroy <lecroy@ids.net>
Date: 2 Mar 1995 16:11:08 GMT
Organization: SouthBeach Software Corp.
Richard Wesley, hawkfish@halcyon.com writes:
> Chris LeCroy <lecroy@ids.net> writes:
>
> > While reading Brian Stern's excellent FAQ on system extensions I came
> > across the statement in answer [2] that goes - "...things that system
> > extensions cannot do (or at least cannot do safely), like launch
> > applications...".
> >
> > Is it unsafe to call LaunchApplication from an extension? Was Brian
> > just referring to INIT time? Are there any tricks/caveats in
> > launching an application from a system extension?
> >
> > Thanks,
>
> I don't believe that the process manager is running at INIT time, so
_Launch
> would probably have either no effect or rather humourous effects. If
you want
> to launch an app, put an alias in the Startup Items folder. You could
even
> have your INIT do this (and remove it if the app was not to be
launched. There
> is also some mechanism involving applications of type 'appe' but I don't
> knowwhat it involves.
I probably wasn't clear enough in my original post. I just want to be
sure that it is safe to call LaunchApplication from an extension that
is being called from a trap patch after everything is up and running.
I've done the 'appe' thing in the past but have recently been thinking
about going at things with a system extension. With the
background-only application approach I was running into some problems
with screen-savers/remote back-up utilities not giving me time for
some reason. Never figured out why and I don't seem to have the
problem with my when doing the same thing from a system extension (ie.
patch).
Rephrasing my original question: Is there any problem with calling
LaunchApplication from a system extension *after* INIT time? I've
been doing so and it *seems* to work, but Brian's comment got me
wunderin'.
Thanks,
Chris LeCroy
SouthBeach Software Corp.
+++++++++++++++++++++++++++
>From BrianS@pbcomputing.com (Brian Stern)
Date: 2 Mar 1995 21:52:05 GMT
Organization: The University of Texas at Austin, Austin, Texas
In article <3j4qms$g2h@paperboy.ids.net>, Chris LeCroy <lecroy@ids.net> wrote:
< Richard Wesley, hawkfish@halcyon.com writes:
< > Chris LeCroy <lecroy@ids.net> writes:
< >
< > > While reading Brian Stern's excellent FAQ on system extensions I came
< > > across the statement in answer [2] that goes - "...things that system
< > > extensions cannot do (or at least cannot do safely), like launch
< > > applications...".
< > >
< > > Is it unsafe to call LaunchApplication from an extension? Was Brian
< > > just referring to INIT time? Are there any tricks/caveats in
< > > launching an application from a system extension?
< > >
< > > Thanks,
< >
< > I don't believe that the process manager is running at INIT time, so
< _Launch
< > would probably have either no effect or rather humourous effects. If
< you want
< > to launch an app, put an alias in the Startup Items folder. You could
< even
< > have your INIT do this (and remove it if the app was not to be
< launched. There
< > is also some mechanism involving applications of type 'appe' but I don't
< > knowwhat it involves.
<
< I probably wasn't clear enough in my original post. I just want to be
< sure that it is safe to call LaunchApplication from an extension that
< is being called from a trap patch after everything is up and running.
< I've done the 'appe' thing in the past but have recently been thinking
< about going at things with a system extension. With the
< background-only application approach I was running into some problems
< with screen-savers/remote back-up utilities not giving me time for
< some reason. Never figured out why and I don't seem to have the
< problem with my when doing the same thing from a system extension (ie.
< patch).
<
< Rephrasing my original question: Is there any problem with calling
< LaunchApplication from a system extension *after* INIT time? I've
< been doing so and it *seems* to work, but Brian's comment got me
< wunderin'.
<
< Thanks,
<
<
< Chris LeCroy
< SouthBeach Software Corp.
The main reason I said that in the FAQ has to do with appleevents. If you
want to send an appleevent to the launched app then you need to build it.
Building an appleevent from an init means that the current process needs
to be high-level-event-aware. Since you don't have control of that it is
risky to try it.
Having said that, if you're not going to build an apple event to send to
the launched app then you can safely use LaunchApplication. It is also
conceiveable that you could wait until you were in the Finder's context to
build your apple event, since the Finder is guaranteed to be
high-level-event-aware.
FWIW I know that the AppleShare extension launches a process when you
start up the AppleShare File Server app. But it sends a high level event,
not an apple event.
Cheers,
--
Brian Stern :-{)}
Toolbox commando and Menu bard. Will FlushCache for Cash.
BrianS@pbcomputing.com
+++++++++++++++++++++++++++
>From jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
Date: 3 Mar 1995 07:32:55 GMT
Organization: Queen Mary & Westfield College
In article <BrianS-0203951600400001@slip-10-4.ots.utexas.edu>
BrianS@pbcomputing.com (Brian Stern) writes:
> < Rephrasing my original question: Is there any problem with calling
> < LaunchApplication from a system extension *after* INIT time? I've
> < been doing so and it *seems* to work, but Brian's comment got me
> < wunderin'.
>
> The main reason I said that in the FAQ has to do with appleevents. If you
> want to send an appleevent to the launched app then you need to build it.
> Building an appleevent from an init means that the current process needs
> to be high-level-event-aware. Since you don't have control of that it is
> risky to try it.
With the greatest respect, Brian, that's not the case. You need to be
HLE-aware to send an apple event, but anyone can build one.
My INIT builds the open doc apple event, coerces it to whatever the
Launch trap requires (I forget exactly) and then calls _Launch. It
works whether or not the frontmost app is HLE-aware, because the event
seems to be "sent" in a special way by _Launch.
Jeremy
---------------------------
>From jshanks@maths.otago.ac.nz (John Shanks)
Subject: My own Color Table??
Date: 28 Feb 1995 08:08:31 GMT
Organization: University of Otago
Surely there is an easy way to do what I want but many hours reading NIM
hasn't helped:
All (??) I want is to open a window with its own color table which I can
then modify to change colors in the window. 256 colors would be fine
(i.e. indexed color) and the window can fill the screen so I don't care
about other applications sharing the colors. Sounds easy....
I have tried all sorts of things with GWorlds and palettes and copying
color tables and modifying them, but nothing works. This kind of thing
used to be a breeze with the Apple //gs (remember that?)
Can anyone point me in the right direction?
Many thanks.
--
John and Louise Shanks
Dunedin
New Zealand
+++++++++++++++++++++++++++
>From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
Date: Wed, 1 Mar 1995 16:59:04 +1300 (NZDT)
Organization: (none)
jshanks@maths.otago.ac.nz (John Shanks) writes:
> Surely there is an easy way to do what I want but many hours reading NIM
> hasn't helped:
>
> All (??) I want is to open a window with its own color table which I can
> then modify to change colors in the window. 256 colors would be fine
> (i.e. indexed color) and the window can fill the screen so I don't care
> about other applications sharing the colors. Sounds easy....
> I have tried all sorts of things with GWorlds and palettes and copying
> color tables and modifying them, but nothing works. This kind of thing
> used to be a breeze with the Apple //gs (remember that?)
It's worked for me no problems.
Try using a table with a fewer than 256 colours at first -- the system can
get a bit snarky if you try to take over all 256, especially if you don't
put black and white where it expects to find them as first and last
entries.
The following worked fine for me, as part of animating a wheel-of-fortune
game:
Var
p: PaletteHandle;
myWindow: WindowPtr;
boundsRect: Rect;
SetRect(boundsRect, 0, 20, 640, 480);
myWindow := NewCWindow(Nil, boundsRect, 'the title', true, nogrowdocproc, WindowPtr(-1), false, 0);
SetPort(myWindow);
p := NewPalette(6 + 210, Nil, pmAnimated, 0);
SetPalette(FrontWindow, p, true);
myColourTab := CTabHandle(Newhandle(0));
Palette2CTab(p, myColourTab);
DrawSectors;
DrawDigits;
AnimatePalette(FrontWindow, myColourTab, 0, 0, 6 + 210);
-- Bruce
---------------------------
>From cerickso@hmc.edu (Chris Erickson)
Subject: Need help with calling CODE resources
Date: Fri, 03 Mar 1995 21:56:10 -0800
Organization: Harvey Mudd College
I'm writing an application that needs to repetitively call an external
code resource via the Time Manager. I found code in Think Ref that loads a
CODE resource into memory and shows you how to call it. It worked fine for
awhile but now it has the tendency to crash with "Spurious Interupt in
_Date2Secs...". This problem disappears if I comment out the code that
actually calls the routine. BTW, the _Date2Secs call is being generated by
the system, not my app.
Here's most the (relevant) code:
extern Handle modularDataProc;
extern DRProcDataPtr theData;
extern TMInfo myTMInfo;
void InstallTMTask (void);
pascal void MyTask (void);
pascal void MyTask()
{
long oldA5; // A5 when task is called
TMInfoPtr recPtr;
recPtr = GetTMInfo(); // first get our TM record
oldA5 = ::SetA5(recPtr->tmRefCon); // Set A5 to app's A5 world
short error = 0, counter = theData->numChannelsInUse - 1;
::PrimeTime( (QElemPtr) recPtr, kDelay );
::HLock(modularDataProc); // Lock the procedure handle
error = (* (modularDataProcPtr) (*modularDataProc)) (kGetData, theData,
0L);
::HUnlock(modularDataProc); // Unlock the procedure handle
// Commenting out above three lines removes problem.
.
.
.
}
Are there any other ways to call a CODE resource? I'm pretty sure (though
not positive) that the code in the call itself is not the culprit.
Thanks,
Chris Erickson
Harvey Mudd College
+++++++++++++++++++++++++++
>From oster@netcom.com (David Phillip Oster)
Date: Sat, 4 Mar 1995 18:02:51 GMT
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
In article <cerickso-0303952156100001@merlin.st.hmc.edu> cerickso@hmc.edu (Chris Erickson) writes:
>Here's most the (relevant) code:
> ::PrimeTime( (QElemPtr) recPtr, kDelay );
> ::HLock(modularDataProc); // Lock the procedure handle
> error = (* (modularDataProcPtr) (*modularDataProc)) (kGetData, theData,
>0L);
> ::HUnlock(modularDataProc); // Unlock the procedure handle
1.) Don't lock and unlock the handle from your interrupt routine. This
is a sure way to corrupt the memory manager. Instead, lock the handle
in your main-line code.
2.) you should be calling StripAddress() before executing the proc
pointer (more efficient to save the StripAddress'ed proc pointer to a global
variable.) because you are running at interrupt time, and on machines that
are normally in 24-bit mode, but switch to 32-bit mode to access video
cards, starange things can happen if the resource-manager's flag bits
don't get stripped before the call.
--
- ------- <mail-to:oster@netcom.com> ----------
There is no sight finer than that of the planet Earth in your rearview mirror.
---------------------------
>From dave@smartstar.com (Dave Schwartz)
Subject: Q: TextEdit view-dest rectangles - documented where?
Date: Thu, 23 Feb 1995 22:51:27 GMT
Organization: SmartStar Corp.
In "Inside Macintosh:Text" ch 2 (TextEdit) there is a rather cursory
description of how the TextEdit uses view and destination rectangles. The
reader is referred to "... the QuickDraw chapters in Inside Macintosh:
Imaging" for more information.
Although I cannot find a volume called "Imaging" in the NIM set, I have
found one called "Imaging with QuickDraw" which seems to have the content
that is described for the "Imaging" volume in the NIM chart on the last
page (backispiece??) of the "Text" volume. However, I have searched
through "Imaging with QuickDraw" for several hours, and the only thing I
came up with is a brief discussion of scaling a picture to fit in a
destination rectangle when using DrawPicture (p 7-18). I have also
searched the CDROM version on the (Reference Library) Developer CD.
I am somewhat of a newbie at graphical interface programming, and I have
inherited some code that seems to misuse the TextEdit by creating a
destination rectangle much larger than the view rectangle even though the
text that is being displayed is _not_ supposed to scroll (this is a short,
single line text entry field with a constrained length).
Before I change it, I'd like to have a better idea of what I'm doing. Can
someone point me to a more detailed explanation of how the view and
destination rectangles are intended to be used? I think that I can call
TEAutoView and use TESelView whenever TEActivate is called, but I'd rather
try to understand the use of the rectangles.
Thanks.
--
Dave Schwartz | "It's the blind leading the blind, and I am amazed
dave@smartstar.com | How they stumble homeward through the haze"
VMS FOREVER | David Crosby
+++++++++++++++++++++++++++
>From brawer@coli.uni-sb.de (Sascha Brawer)
Date: Tue, 28 Feb 1995 17:42:02 +0100
Organization: Dept. of Comp. Linguistics, Uni des Saarlandes, DE
In article <dave-2302951447490001@crosby.smartstar.com>,
dave@smartstar.com (Dave Schwartz) wrote:
> [...] Can someone point me to a more detailed explanation of how the view and
> destination rectangles are intended to be used?
Use the view rectangle for the area where text shall be visible (i.e. the box
to enter the text); use the destination rectangle for the "logical" size of
the text. The wrapping of the text is performed according to the destRect
(ignoring its bottom edge), but the drawing will be clipped to the
viewRect.
See the *old* Inside Macintosh, Vol. I, p. I-374, or consider the picture
in the New Inside Mac.: Text, p. 2-16.
At the latter location, consider the right of the two images: Only the
grey-shaded part will be visible on the screen, and to see the non-shaded
part of the text, the user will have to scroll with the mouse or by using
the cursor keys.
-- Sascha Brawer
- -------------------------------------------------------------------
Sascha Brawer (Student of Computational Linguistics)
e-Mail: brawer@coli.uni-sb.de
URL: http://coli.uni-sb.de/~brawer/
Address: Stengelstrasse 18, D-66117 Saarbruecken
Phone: (+49 681) 589 85 66
- -------------------------------------------------------------------
---------------------------
>From bb@lightside.com (Bob Bradley)
Subject: Q: What are Exceptions?
Date: 27 Feb 1995 10:29:19 GMT
Organization: SPC
What are exceptions? I've seen a lot of people talking about them but, I'm
not sure what they are or how they are better than what people are using
without them. I assume they are some form of error detection or how errors
are handled. How are they better than the regular "if an error occured,
display error" type error handling?
+++++++++++++++++++++++++++
>From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
Date: Mon, 27 Feb 1995 14:49:20 -0500
Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
Excerpts from netnews.comp.sys.mac.programmer.misc: 27-Feb-95 Q: What
are Exceptions? Bob Bradley@lightside.co (331*)
> What are exceptions? I've seen a lot of people talking about them but, I'm
> not sure what they are or how they are better than what people are using
> without them. I assume they are some form of error detection or how errors
> are handled.
The idea is that you can execute a statement with an error handler.
Typical syntax (from C++) is:
try { STATEMENT }
catch (ERROR TYPE) { HANDLER-STATEMENT };
Then, if the statement encounters an error, it can throw an exception of
the appropriate type. This causes the statement to immediately stop
executing, and control goes straight to the handler.
This may sound like a baroque way to write "if (!error) {...}", and on
the simplest level it is. The strength of the technique is that
exceptions can be thrown from inside nested functions called by
STATEMENT; each function aborts and exits until control reaches the
handler. If there is no handler, the entire program exits with a
run-time error. (There are more details, of course; you can typically
have multiple handlers and handlers that throw more exceptions and
whatever.)
Like any tool, you can use this well or stupidly. I find myself writing
a lot of code which has several interacting procedures, each of which
does some stuff and returns an error code or noErr, and every step is
followed by "if (error) return error;". If I used exceptions, I could
get the same effect without wasting verbiage on that sort of thing. It
also keeps you from wasting the function's return value on
error-checking.
Sadly, I'm using C, and there ain't no exceptions to use. Sigh.
Another example: you open a file, and then call some complicated
file-diddling code. The file-diddling can encounter all sorts of errors
caused by bad file format. Rather than writing code to unwind the data
you've loaded and close the file after each error, you put on an
exception handler that does all that.
Some people hate handlers because they remind them of "goto". I like
handlers because they remind me of "break" and "return", only more
flexible.
--Z
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
+++++++++++++++++++++++++++
>From jens_alfke@powertalk.apple.com (Jens Alfke)
Date: Tue, 28 Feb 1995 21:27:05 GMT
Organization: Apple Computer, Inc.
In article <ojIWn0_00gpI1oAmck@andrew.cmu.edu>, "Andrew C. Plotkin"
<ap1i+@andrew.cmu.edu> wrote:
> Sadly, I'm using C, and there ain't no exceptions to use. Sigh.
Not true; you can fake exception handling using setjmp and longjmp just
like C++ programmers do. One thing I did a long time ago was take code
from the TCL that does exception handling; it doesn't use any non-C
features. (This may have changed with the newer versions of the TCL.)
Basically it takes about 1k of code to do a pretty good simulation of
exception handling.
Jens Alfke_________OpenDoc Geometer_________jens_alfke@powertalk.apple.com
OpenDoc info: FTP to CILabs.org
Visit Scenic Flood Control Dam No. 3.
---------------------------
>From Nick Clarke: <74730.1570@CompuServe.COM>
Subject: Screen saver info needed
Date: 28 Feb 1995 10:18:57 GMT
Organization: The BootRoom
Screen saver info needed
I am trying to write a control panel that is a screen saver. I am a
bit stuck about what to do. I have a few questions.
1) How do you save data, ie the number of minutes before saver
activates?
2) I presume I have to insert a VBL task. Do I call it once with
the time setting to be the number of ticks before activation, or
regularly?
3) How after the activation time, do I handle the call back when it
is from a control panel?
4) When I patch GetNextEvent etc I assume that I clear the VBL task
and reset it between each event
5) Are there any other pitfalls I should look out for?
Thanks
Nick Clarke
--
Nick Clarke: The BootRoom: 74730.1570@compuserve.com.
+++++++++++++++++++++++++++
>From Matt Slot <fprefect@umich.edu>
Date: 28 Feb 1995 14:47:04 GMT
Organization: University of Michigan
Nick Clarke:, 74730.1570@CompuServe.COM writes:
> 1) How do you save data, ie the number of minutes before saver
> activates?
Storing globals is highly dependent on your development environment.
THINK C
uses a strangely different system for keeping global data in a Code
resource,
etc. I would suggest that you look for sample source and for the dox about
the particulars, or repost with that info (actually it may be in the FAQ).
> 2) I presume I have to insert a VBL task. Do I call it once with
> the time setting to be the number of ticks before activation, or
> regularly?
Typically there is no need to have a VBL task. You can get time to
work by patching something mundane like SystemTask() -- VBL's are a
bit of overkill.
> 3) How after the activation time, do I handle the call back when it
> is from a control panel?
Your Code resource should leave itself locked, then call RecoverHandle()
and
DetachResource() at your startup -- then your code is left in memory.
When you patch a routine (at least globally), the patch should simply be
with a second function from your Code resource.
> 4) When I patch GetNextEvent etc I assume that I clear the VBL task
> and reset it between each event
I would discourage you from patching GetNextEvent(), but rather look at
the jGNEFilter samples and tracking the mouse position.
> 5) Are there any other pitfalls I should look out for?
Start with the thoughts above... look at the FAQ and some sample source.
There are several pitfalls, and you will have more info on resolving the
problems.
+++++++++++++++++++++++++++
>From Nick Clarke: <74730.1570@CompuServe.COM>
Date: 28 Feb 1995 19:03:15 GMT
Organization: The BootRoom
Matt
Thanks for the advice - I'll try your suggestions: Couple more
things: Where can I get the FAQ and do you know where I can get some
sample source code for Control Panel (ideally a screen saver). This
may help me plan better
Nick
--
Nick Clarke: The BootRoom: 74730.1570@compuserve.com.
+++++++++++++++++++++++++++
>From h+@metrowerks.com (Jon W{tte)
Date: Sat, 04 Mar 1995 12:10:33 +0100
Organization: The Conspiracy
In article <3iutah$6cc$1@mhade.production.compuserve.com>,
Nick Clarke: <74730.1570@CompuServe.COM> wrote:
> 1) How do you save data, ie the number of minutes before saver
> activates?
In a preferences file in the preferences folder (use FindFolder
to find the Preferences folder)
> 2) I presume I have to insert a VBL task. Do I call it once with
> the time setting to be the number of ticks before activation, or
> regularly?
Uh, no, you don't need a VBL task. If you install one, the
system will call it for you regularly, [a multiple of] each
time the screen goes through a vertical blanking period (i e
when the electron beam goes from bottom to top to repaint the
screen) This happens 50-80 times a second.
> 3) How after the activation time, do I handle the call back when it
> is from a control panel?
Your control panel must have an INIT part that installs code in
the system heap.
> 4) When I patch GetNextEvent etc I assume that I clear the VBL task
> and reset it between each event
Don't patch GetNextEvent. If you want to get into that
functionality, you should use the jGNEFilter. There is
something called the jGNEFilter helper on the archives with
sample code.
> 5) Are there any other pitfalls I should look out for?
Yes; don't write an INIT/Control Panel combo. Patching traps
with 68K code hurts performance on PowerPC systems really bad.
There are tens of freeware screen savers out there, along with
several shareware and commercialware ones. Why write your own?
When in "blanking" mode, how do you expect to keep up
background processing? How do you expect to stop other
applications from drawing to the screen?
The correct thing to do, which doesn't patch anything at all,
is to write an APPLICATION which, on WaitNextEvent idle time,
checks for keys down or button down, and resets its internal
counter. Once it's time to fade, it opens a window and sets
itself to front with SetFrontProcess(). This is <simplified>
what Dark Side of the Mac does; the premier non-commercial Mac
screen saver. Check it out. Do something useful with your time.
Cheers,
/ h+
--
Jon Wdtte (h+@metrowerks.com), Hagagatan 1, 113 48 Stockholm, Sweden
"These really aren't my opinions. I just fed them and they followed me home."
---------------------------
>From quag@netcom.com (Matt Quagliana)
Subject: Transparent QuickTime?
Date: Thu, 16 Feb 1995 16:54:08 GMT
Organization: Cerebus Corporation
I am trying to do something with QuickTime that might not be possible,
but I can't find any information to either confirm or deny my suspicion.
I am writing an application using Novell AppWare, a high level visual
programming tool. The exact choice of tools shouldn't matter, but I
mention it because I am not working at the C/C++ level.
In AppWare I have the ability to display PICT images in windows, and to
play QuickTime movies in windows. What I want to do is play a QuickTime
movie *in front of* a picture, so that the movie is superimposed on the
static image.
Currently, this doesn't work because the QuickTime rectangle masks out
everything below it, i.e. my movie plays inside a box of white space,
hiding the picture behind it.
Does QuickTime support the ability to create and play movies with
transparent backgrounds, or am I SOL?
Thanks in advance...
Matt Quagliana
Cerebus Corporation
quag@cerebus.com
(214) 855-0880
+++++++++++++++++++++++++++
>From Scott Hutinger <S-Hutinger@bgu.edu>
Date: 16 Feb 1995 21:25:07 GMT
Organization: Macomb Projects
In article <quagD43qy8.C77@netcom.com> Matt Quagliana, quag@netcom.com
writes:
>In AppWare I have the ability to display PICT images in windows, and to
>play QuickTime movies in windows. What I want to do is play a QuickTime
>movie *in front of* a picture, so that the movie is superimposed on the
>static image.
>
>Currently, this doesn't work because the QuickTime rectangle masks out
>everything below it, i.e. my movie plays inside a box of white space,
>hiding the picture behind it.
>
>Does QuickTime support the ability to create and play movies with
>transparent backgrounds, or am I SOL?
What I do is
1) make the background picture
2) copy the size and location of where the movie is going to play on top
of the picture.
3) put that picture as the background in the movie (using a Quicktime
editor)
4) chromakey someone into the movie
5) play the movie back onto the same location I stole the picture from.
Then you have the Heavy Metal girls in your application! But, to answer
your question, I don't think your application will support any masks or
other things you can do with quicktime, other than play a movie.
Is the picture behind the movie the same size as the movie itself? If
so, your SOL, unless you make your movie the way I do.
scott
s-hutinger@bgu.edu
+++++++++++++++++++++++++++
>From ldo@waikato.ac.nz (Lawrence D9Oliveiro)
Date: Fri, 17 Feb 1995 17:14:49 +1300
Organization: University of Waikato
In article <quagD43qy8.C77@netcom.com>, quag@netcom.com (Matt Quagliana) wrote:
>What I want to do is play a QuickTime
>movie *in front of* a picture, so that the movie is superimposed on the
>static image.
>
>Currently, this doesn't work because the QuickTime rectangle masks out
>everything below it, i.e. my movie plays inside a box of white space,
>hiding the picture behind it.
>
>Does QuickTime support the ability to create and play movies with
>transparent backgrounds, or am I SOL?
Yes, you certainly can do this. Look for the SetVideoMediaGraphicsMode
call: this lets you specify any QuickDraw drawing mode for a video track,
including transparent mode.
However, it's not enough to make a single track transparent: you'll just
get bits of garbage wherever the transparent colour appears in a frame. In
order to get the static image to draw in the transparent parts, you have
to make that image a video track in the movie in its own right, positioned
behind the moving track. This background track only needs to contain a
single frame with a very long duration, so the size it would add to your
movie is minimal.
Note that using such fancy drawing modes would probably add a performance
penalty to your movie.
+++++++++++++++++++++++++++
>From soori@netcom.com (Mahesh Sooriarachchi)
Date: Tue, 21 Feb 1995 00:47:33 GMT
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
You can give a mask (RgnHandle) to q quicktime moview that will be used
to clip the movie. What I would do is to create a B/W PICTure that is
the mask you want, creae a 1 bit gWorld, draw the b/w picture into it,
call PixMapToRegion() to create the mask you want, then set the movie's mask
by calling SetTrackClipRgn() for the track.
Good Luck.
In article
<quagD43qy8.C77@netcom.com> quag@netcom.com (Matt Quagliana) writes:
>I am trying to do something with QuickTime that might not be possible,
>but I can't find any information to either confirm or deny my suspicion.
>
>I am writing an application using Novell AppWare, a high level visual
>programming tool. The exact choice of tools shouldn't matter, but I
>mention it because I am not working at the C/C++ level.
>
>In AppWare I have the ability to display PICT images in windows, and to
>play QuickTime movies in windows. What I want to do is play a QuickTime
>movie *in front of* a picture, so that the movie is superimposed on the
>static image.
>
>Currently, this doesn't work because the QuickTime rectangle masks out
>everything below it, i.e. my movie plays inside a box of white space,
>hiding the picture behind it.
>
>Does QuickTime support the ability to create and play movies with
>transparent backgrounds, or am I SOL?
>
>Thanks in advance...
>
>Matt Quagliana
>Cerebus Corporation
>quag@cerebus.com
>(214) 855-0880
--
Lets DIVIDE and conquer the Pentium!
PowerPC to the rescue!
Mahesh Soori. - My openions are mine, not of my employer!
+++++++++++++++++++++++++++
>From f94mad@efd.lth.se (Markus Andreasson)
Date: 23 Feb 1995 09:14:31 GMT
Organization: Lund Institute of Technology, Sweden
In article <quagD43qy8.C77@netcom.com>, quag@netcom.com (Matt Quagliana) writes:
> I am trying to do something with QuickTime that might not be possible,
> but I can't find any information to either confirm or deny my suspicion.
>
> I am writing an application using Novell AppWare, a high level visual
> programming tool. The exact choice of tools shouldn't matter, but I
> mention it because I am not working at the C/C++ level.
>
> In AppWare I have the ability to display PICT images in windows, and to
> play QuickTime movies in windows. What I want to do is play a QuickTime
> movie *in front of* a picture, so that the movie is superimposed on the
> static image.
>
> Currently, this doesn't work because the QuickTime rectangle masks out
> everything below it, i.e. my movie plays inside a box of white space,
> hiding the picture behind it.
>
> Does QuickTime support the ability to create and play movies with
> transparent backgrounds, or am I SOL?
>
> Thanks in advance...
I'm playing QuickTime movies in front of pictures in Director. I just
give the movie a transparent background and it works fine (if the movie's
original background is white). Perhaps there's a similar option in Novell
AppWare?
_._._
Markus Andreasson f94mad@efd.lth.se
+++++++++++++++++++++++++++
>From fixer@faxcsl.dcrt.nih.gov (Chris Tate)
Date: Thu, 23 Feb 1995 13:52:46 GMT
Organization: DCRT, NIH, Bethesda, MD
In article <quagD43qy8.C77@netcom.com>, quag@netcom.com (Matt Quagliana) writes:
>
>I am trying to do something with QuickTime that might not be possible,
>but I can't find any information to either confirm or deny my suspicion.
>
> [....]
>
>In AppWare I have the ability to display PICT images in windows, and to
>play QuickTime movies in windows. What I want to do is play a QuickTime
>movie *in front of* a picture, so that the movie is superimposed on the
>static image.
>
>Currently, this doesn't work because the QuickTime rectangle masks out
>everything below it, i.e. my movie plays inside a box of white space,
>hiding the picture behind it.
It's possible, but it's tricky. Actually, it's pretty slick, but it's still
quite a bit more trouble than simply playing a QuickTime movie directly into
a window.
You need to dig down into animation techniques yourself for this. The most
straightforward technique requires that you have three (possibly only two)
offscreen buffers (use GWorlds):
1) The window contents, without any movie data cluttering it up
2) A GWorld to play the movie into
3) A scratch buffer
For every frame of the movie (!), you copy buffer 1) into buffer 3). This
gives you, at every frame, a 'plain' background image. Then, you draw one
frame of the QuickTime movie into buffer 2). Next, you use CopyBits() with
an appropriate transfer mode or mask to blit *just the 'opaque' parts of
the movie frame* on top of the background image in buffer 3). At this point,
buffer 3) consists of the 'background' image, overlaid with the current frame
of the QT movie.
Finally, you blit buffer 3) onto the screen.
Yeah, this sounds slow. The problem is that QuickTime can't support this
sort of thing directly; it has no way of knowing what image data it has
overwritten in your window, and so you have to have some way of restoring
the 'background' image for every frame of the movie.
If someone has a better approach than this, I'd love to hear about it... :-)
For what it's worth, there's a guy at Apple who used similar techniques on
a PowerMac to get respectable animation speed doing realtime image mapping
of a running QuickTime movie onto a rotating, moving 3D surface (a cube, or
a cylinder, or a Bezier surface, or....). So, this sort of thing *can* work
fast enough to be usable, at least on a PowerMac.
- ----------------------------------------------------------
Christopher Tate | "I love it when you use me as
fixer@faxcsl.dcrt.nih.gov | a split-screen montage!"
eWorld: cTate | -- "Whose Line Is It Anyway?"
+++++++++++++++++++++++++++
>From rudolph@unixg.ubc.ca (Chris Rudolph)
Date: Thu, 23 Feb 1995 08:30:38 -0800
Organization: Motion Works International
In article <1995Feb23.135246.17516@alw.nih.gov>, fixer@faxcsl.dcrt.nih.gov
wrote:
> It's possible, but it's tricky. Actually, it's pretty slick, but it's still
> quite a bit more trouble than simply playing a QuickTime movie directly into
> a window.
>
> You need to dig down into animation techniques yourself for this. The most
> straightforward technique requires that you have three (possibly only two)
> offscreen buffers (use GWorlds):
>
> 1) The window contents, without any movie data cluttering it up
> 2) A GWorld to play the movie into
> 3) A scratch buffer
>
Dohhhhhhhh!
That would use up alot of memory needlessly. Here is a better way of
doing what you want, assuming you know where on top of the Picture you
intend to play the movie.
Create an offscreen gworld ( use temporary memory, since we only need it
for a short time ) that is the same size as the movie.
Image the Picture into the offscreen, without scaling.
Get the first video track in the movie, create a new video track, and copy
the settings of the first track to the new track.
Enable the new track.
Create a new media sample using the gworld sample data as the data
reference, and dhlr type as 'hndl'.
BeginMediaEdits - AddMediaSample - EndMediaEdits.
Insert the media into the new track, scale the track segment to be the
same size as the duration of the movie.
Set the layering of the new track ( SetTrackLayer ) to a value greater
than the first video track.
Get the mediahandler for the first video track and call
MediaSetGraphicsMode with a transparent setting and white as the operand
color.
Get the mediahandler for the new video track and call MediaSetGraphicsMode
with a srcCopy setting and black as the operand color.
Play the movie.
Thats all there is to it. I'll happily answer any questions regarding this.
- -------------------------------------------------------------------
Chris Rudolph, Senior Engineer,
Technology Works.
Motion Works International.
Internet: rudolph@unixg.ubc.ca
AppleLink: D2276 ( Subject: Attn: Chris Rudolph )
- -------------------------------------------------------------------
+++++++++++++++++++++++++++
>From ivanski@world.std.com (Ivan M CaveroBelaunde)
Date: Thu, 2 Mar 1995 04:42:10 GMT
Organization: The World Public Access UNIX, Brookline, MA
rudolph@unixg.ubc.ca (Chris Rudolph) writes:
>In article <1995Feb23.135246.17516@alw.nih.gov>, fixer@faxcsl.dcrt.nih.gov
>wrote:
>That would use up alot of memory needlessly. Here is a better way of
>doing what you want, assuming you know where on top of the Picture you
>intend to play the movie.
>Create an offscreen gworld ( use temporary memory, since we only need it
>for a short time ) that is the same size as the movie.
>Image the Picture into the offscreen, without scaling.
>Get the first video track in the movie, create a new video track, and copy
>the settings of the first track to the new track.
>Enable the new track.
>Create a new media sample using the gworld sample data as the data
>reference, and dhlr type as 'hndl'.
>BeginMediaEdits - AddMediaSample - EndMediaEdits.
>Insert the media into the new track, scale the track segment to be the
>same size as the duration of the movie.
>Set the layering of the new track ( SetTrackLayer ) to a value greater
>than the first video track.
>Get the mediahandler for the first video track and call
>MediaSetGraphicsMode with a transparent setting and white as the operand
>color.
>Get the mediahandler for the new video track and call MediaSetGraphicsMode
>with a srcCopy setting and black as the operand color.
>Play the movie.
Actually, it 's not even necessary to create a track with the background
image. HJust set the media graphics mode for the frontmost video
track, and use the SetMovieCoverProcs call to draw the movie's
background.
-Ivan
- -
Ivan Cavero Belaunde (ivanski@world.std.com, ivan_cavero-belaunde@avid.com)
Avid Technology, Inc.
---------------------------
End of C.S.M.P. Digest
**********************